﻿namespace NavigateTo2013
{
    using Microsoft.VisualStudio.Language.NavigateTo.Interfaces;
    using System.IO;

    public class NavigateToItemDisplayFactory : INavigateToItemDisplayFactory
    {
        public bool IsMoreClicked { get; set; }

        public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item)
        {            
            if (item.Kind == SearchEngine.More)
            {
                return new NavigateToItemDisplay
                {
                    FileName = item.Kind,
                    FilePath = string.Empty,
                    Task = item.Tag as Task,
                    Factory = this,
                };
            }

            return new NavigateToItemDisplay 
            {
                FileName = File.Exists(item.Kind) ? Path.GetFileName(item.Kind) : item.Kind,
                FilePath = item.Kind,
                Task = item.Tag as Task,
                Factory = this
            };
        }
    }
}